package com.lin.pan.server.modules.user.converter;

import com.lin.pan.server.modules.file.entity.RPanUserFile;
import com.lin.pan.server.modules.user.Vo.UserInfoVO;
import com.lin.pan.server.modules.user.context.*;
import com.lin.pan.server.modules.user.entity.RPanUser;
import com.lin.pan.server.modules.user.po.*;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;

/**
 * 用户模块实体转化工具类
 */
@Mapper(componentModel = "spring")
public interface UserConverter {

    /**
     * UserRegisterPO转化成UserRegisterContext
     *
     * @param userRegisterPO
     * @return
     */
    UserRegisterContext userRegisterPO2UserRegisterContext(UserRegisterPO userRegisterPO);



    /**
     * UserRegisterContext转RPanUser
     *
     * @param userRegisterContext
     * @return
     */
    @Mapping(target = "password", ignore = true)
    RPanUser userRegisterContext2RPanUser(UserRegisterContext userRegisterContext);

    /**
     * UserLoginPO转UserLoginContext
     *
     * @param userLoginPO
     * @return
     */
    UserLoginContext userLoginPO2UserLoginContext(UserLoginPO userLoginPO);

    /**
     * CheckUsernamePo转CheckUsernameContext
     * @param checkUsernamePo
     * @return
     */
    CheckUsernameContext checkUsernamePo2CheckUsernameContext(CheckUsernamePo checkUsernamePo);

    /**
     * CheckAnswerPo转CheckAnswerContext
     * @param checkAnswerPo
     * @return
     */
    CheckAnswerContext checkAnswerPo2CheckAnswerContext(CheckAnswerPo checkAnswerPo);

    /**
     * ResetPasswordPo转ResetPasswordContext
     * @param resetPasswordPo
     * @return
     */
    ResetPasswordContext resetPasswordPo2ResetPasswordContext(ResetPasswordPo resetPasswordPo);

    /**
     * ChangePasswordPo转ChangePasswordContext
     * @param changePasswordPo
     * @return
     */
    ChangePasswordContext changePasswordPo2ChangePasswordContext(ChangePasswordPo changePasswordPo);

    /**
     * 拼装用户基本信息返回实体
     *
     * @param rPanUser
     * @param rPanUserFile
     * @return
     */
    @Mapping(source = "rPanUser.username", target = "username")
    @Mapping(source = "rPanUserFile.fileId", target = "rootFileId")
    @Mapping(source = "rPanUserFile.filename", target = "rootFilename")
    UserInfoVO assembleUserInfoVO(RPanUser rPanUser, RPanUserFile rPanUserFile);

}
